<script lang="jsx" setup>
import dayjs from 'dayjs';
import { computed, nextTick, ref } from 'vue';

const commonSearchRef = ref(null);
const tableRef = ref(null);
const searchParams = ref({
  // moduleNo: null,
  // lotId: null,
  // pnlId: null,
  time: null
});

const searchFormList = [
  {
    type: 'dateRangePicker',
    key: 'time',
    label: '日期',
    span: 24,
    md: 12,
    lg: 10,
    xl: 8,
    xxl: 6,
    showTime: true // 显示时分秒选择
  }
];

const searchData = computed(() => {
  const params = {
    ...searchParams.value
  };
  if (searchParams.value?.time?.[0]) {
    params.startTime = dayjs(searchParams.value.time[0]).format('YYYY-MM-DD HH:mm:ss');
    params.endTime = dayjs(searchParams.value.time[1]).format('YYYY-MM-DD HH:mm:ss');
  }
  delete params.time;
  return params;
});

// 表格数据
const column = [
  {
    key: 'dataIndex',
    dataIndex: 'dataIndex',
    title: '序号',
    fixed: 'left',
    width: 70,
    align: 'center',
    checked: true,
    ellipsis: true
  },

  {
    key: 'mainEqpId',
    dataIndex: 'mainEqpId',
    title: '设备编号',
    align: 'center',
    width: 100,
    checked: true,
    ellipsis: true,
    fixed: 'left'
  },
  {
    key: 'itemName1',
    dataIndex: 'itemName1',
    title: '输送速度_设定值 mm/min',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName2',
    dataIndex: 'itemName2',
    title: '输送速度_实时值 mm/min',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName3',
    dataIndex: 'itemName3',
    title: '除油温度_设定值 ℃',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName4',
    dataIndex: 'itemName4',
    title: '除油温度_实时值 ℃',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName5',
    dataIndex: 'itemName5',
    title: '微蚀1温度_设定值 ℃',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName6',
    dataIndex: 'itemName6',
    title: '微蚀1温度_实时值 ℃',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName7',
    dataIndex: 'itemName7',
    title: '微蚀2温度_设定值 ℃',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName8',
    dataIndex: 'itemName8',
    title: '微蚀2温度_实时值 ℃',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName9',
    dataIndex: 'itemName9',
    title: '酸洗温度_设定值 ℃',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName10',
    dataIndex: 'itemName10',
    title: '	酸洗温度_实时值 ℃',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName11',
    dataIndex: 'itemName11',
    title: '	热风吹干温度_设定值 ℃',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName12',
    dataIndex: 'itemName12',
    title: '	热风吹干温度_实时值 ℃',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName13',
    dataIndex: 'itemName13',
    title: '	开机时间累积',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName14',
    dataIndex: 'itemName14',
    title: '	运行时间累积 h',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName15',
    dataIndex: 'itemName15',
    title: '	总产量 h',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName16',
    dataIndex: 'itemName16',
    title: '	批次产量 PNL',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName17',
    dataIndex: 'itemName17',
    title: '	设备总用电量 PNL',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName18',
    dataIndex: 'itemName18',
    title: '	设备DI水总用水量 kWh',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName19',
    dataIndex: 'itemName19',
    title: '	设备自来水总用水量 m3',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName20',
    dataIndex: 'itemName20',
    title: '	板宽设置_设定值 m3',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName21',
    dataIndex: 'itemName21',
    title: '	正残铜率_设定值 mm',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName22',
    dataIndex: 'itemName22',
    title: '	反残铜率_设定值 %',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName23',
    dataIndex: 'itemName23',
    title: '	硫酸添加板长_设定值 %',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName24',
    dataIndex: 'itemName24',
    title: '	硫酸添加面积_设定值 in(英寸)',
    align: 'center',
    width: 250,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName25',
    dataIndex: 'itemName25',
    title: '	硫酸添加时间_设定值 m2',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName26',
    dataIndex: 'itemName26',
    title: '	双氧水板长_设定值 s',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName27',
    dataIndex: 'itemName27',
    title: '	双氧水面积_设定值 in(英寸)',
    align: 'center',
    width: 250,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName28',
    dataIndex: 'itemName28',
    title: '	双氧水添加时间_设定值 m2',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName29',
    dataIndex: 'itemName29',
    title: '	硫酸添加板长_实时值 s',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName30',
    dataIndex: 'itemName30',
    title: '	硫酸添加面积_实时值 in(英寸)',
    align: 'center',
    width: 250,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName31',
    dataIndex: 'itemName31',
    title: '	双氧水板长_实时值 m2',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'itemName32',
    dataIndex: 'itemName32',
    title: '	双氧水面积_实时值 in(英寸)',
    align: 'center',
    width: 200,
    checked: true,
    ellipsis: true
  },
  {
    key: 'dateTime',
    dataIndex: 'dateTime',
    title: '创建时间',
    width: 150,
    align: 'center',
    checked: true,
    ellipsis: true,
  },
];

function search() {
  tableRef.value.getData(1);
}

function reset() {
  nextTick(() => {
    searchParams.value = {
      // moduleNo: null,
      // lotId: null,
      // pnlId: null,
      time: null
    };
    search();
  });
}
</script>

<template>
  <div
    class="code-whitelist-page jl-main-page min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto"
  >
    <CommonSearch
      ref="commonSearchRef"
      v-model:searchParams="searchParams"
      :form-list="searchFormList"
      :is-search="true"
      @search="search"
      @reset="reset"
    ></CommonSearch>

    <Table
      ref="tableRef"
      v-model:searchParams="searchData"
      :column="column"
      :show-row-selection="false"
      :auto-generate-uuid="true"
      :scroll="{ y: 'auto' }"
      is-init-get-data
      url="eap/EapEqpTrace2/selectTianHuaQcl"
    ></Table>
  </div>
</template>

<style lang="scss" scoped></style>
